<!--
 * @Author: xuzehan 123@qq.com
 * @Date: 2023-04-11 14:14:15
 * @LastEditors: xuzehan 935351619@qq.com
 * @LastEditTime: 2024-05-23 11:20:21
 * @FilePath: \ant-design-vue-jeecg-master\src\views\taskManagement\taskAllocation.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div class="taskAllocation">
    <a-collapse v-model="activeKey">
      <a-collapse-panel key="1" header="资源分配">
        <h2>
          指控车资源分配情况
          <!-- 导弹资源分配 -->
          <!-- <a-button @click="handleConfig" type="primary" style="margin-left: 10px">配置详情</a-button> -->
        </h2>
        <a-form-model :model="form" :label-col="labelCol1" :wrapper-col="wrapperCol1">
          <a-row>
            <a-col :span="8">
              <a-form-model-item label="指控车">
                <a-select @change="changeCar" v-model="form1.ncvName" placeholder="请选择">
                  <a-select-option
                    v-for="item in carList"
                    :key="item.id"
                    :value="item.identificationCode"
                  >
                    {{
                    item.name
                    }}({{item.identificationCode}})
                  </a-select-option>
                </a-select>
                <!-- <a-input v-model="form1.ncvName" read-only></a-input> -->
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="导弹总数">
                <!-- <a-input-number
                  read-only
                  :style="{ width: '100%' }"
                  :max="32"
                  :min="0"
                  v-model="form1.applyMissileTotal"
                  placeholder="最多32个"
                ></a-input-number>-->
                <a-input read-only v-model="form1.applyMissileTotal"></a-input>
                <!-- <a-select v-model="form1.ball" placeholder="请选择">
                  <a-select-option value="1"> 导弹1 </a-select-option>
                  <a-select-option value="2"> 导弹2 </a-select-option>
                  <a-select-option value="3"> 导弹3 </a-select-option>
                  <a-select-option value="4"> 导弹4 </a-select-option>
                </a-select>-->
              </a-form-model-item>
            </a-col>
            <a-col :span="8">
              <a-form-model-item label="分配信道总数">
                <a-input v-model="form1.applyDigitalFilterTotal" read-only />
              </a-form-model-item>
            </a-col>
          </a-row>

          <a-card title="导弹资源配置" style="width: 100%">
            <!-- <a-card title="中频滤波器开关状态" style="width: 100%"> -->
            <a-form-model
              ref="ruleFormZP"
              :label-col="labelCol1"
              :rules="rules"
              :wrapper-col="wrapperCol1"
              :model="formInline"
            >
              <a-row>
                <a-col :span="8">
                  <a-form-model-item label="L可控接收机" prop="LControllableReceiver">
                    <a-select v-model="formInline.LControllableReceiver">
                      <a-select-option value="1">L可控接收机1</a-select-option>
                      <a-select-option value="2">L可控接收机2</a-select-option>
                      <!-- <a-select-option
                        v-for="(item, index) in localOscillatorList"
                        :key="index"
                        :value="item.value"
                      >{{ item.label }}H</a-select-option>-->
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="L本振编号" prop="localOscillator">
                    <a-select
                      default-value="0"
                      @change="changeLocalOscillator"
                      v-model="formInline.localOscillator"
                    >
                      <a-select-option
                        v-for="(item, index) in localOscillatorList"
                        :key="index"
                        :value="item.value"
                      >{{ item.label }}H</a-select-option>
                    </a-select>
                  </a-form-model-item>
                </a-col>
                <a-col :span="8">
                  <a-form-model-item label="中心频点" prop="cfp">
                    <a-input v-model="formInline.cfp" placeholder=" " read-only addon-after="MHz"></a-input>
                  </a-form-model-item>
                </a-col>
                <!-- <a-col :span="8">
                  <a-form-model-item :label-col="{ span: 3 }" :wrapper-col="{ span: 5 }">
                    <a-button
                      type="primary"
                      style="margin-left: 10px"
                      @click="handleSend('ZPLBQPZ')"
                    >发送</a-button>
                  </a-form-model-item>
                </a-col>-->
              </a-row>
              <a-row>
                <a-col :span="8">
                  <a-form-model-item label="中频滤波器">
                    <p style="line-height: 40px;">
                      <span class="on">开</span>
                      <span class="off">关</span>
                      <span class="dis">禁用</span>
                    </p>
                  </a-form-model-item>
                </a-col>
                <a-col :span="24">
                  <div class="ZPLBQList">
                    <div v-for="item in ZPLBQList" :key="item.id" class="ZPLBQBox">
                      <a-popover title="详情" v-if="!item.disabled">
                        <div
                          @click="changeCheckS(item)"
                          :class="!item.disabled ? (item.check ? 'oncheck' : 'offcheck') :'disabledStyle'"
                        >{{ item.label }}</div>
                        <template slot="content">
                          <p>中频滤波器编号：{{ item.no }}</p>
                          <p>中频滤波器带宽：{{ item.DK }}MHz</p>
                          <p>中频滤波器中心频点：{{ item.ZXPD }}</p>
                        </template>
                      </a-popover>
                      <div
                        v-else
                        @click="changeCheckS(item)"
                        :class="!item.disabled ?  (item.check ? 'oncheck' :'offcheck'):'disabledStyle'"
                      >{{ item.label }}</div>
                    </div>
                  </div>
                </a-col>
              </a-row>
            </a-form-model>
            <a-form-model v-bind="layout" :model="formInline" style="margin-top:30px">
              <a-row>
                <a-col :span="24">
                  <a-form-model-item
                    label="数字滤波器"
                    :label-col="{ span: 3 }"
                    :wrapper-col="{ span: 18 }"
                  >
                    <div style="line-height: 40px; color: #fff; display: flex; align-items: start">
                      <span class="on">开</span>
                      <span class="off">关</span>
                      <span class="dis">禁用</span>
                      <span class="occ">占用</span>
                      <div style="display: flex; margin-left: 30px">
                        <p style>注意:数字滤波器配置尽量满足相邻的信道不同时处于“开”的状态</p>
                      </div>
                      <!-- <a-button
                        type="primary"
                        style="margin-left: 50px"
                        @click="handleSend('SZLBQPZ')"
                      >发送</a-button>-->
                    </div>
                  </a-form-model-item>
                </a-col>
                <a-col :span="24">
                  <div class="SZLBQList">
                    <div v-for="item in SZLBQList" :key="item.id" class="SZLBQBox">
                      <a-popover title="详情" v-if="!item.disabled">
                        <div
                          @click="changeCheckSZLBQ(item.id)"
                          :class="!item.disabled ?(item.check ? 'oncheck' : 'offcheck') :(item.occupied?'occupiedCheck':'disabledStyle')"
                        >{{ item.label }}</div>
                        <template slot="content">
                          <p>数字滤波器编号：{{ item.id }}</p>
                          <p>数字滤波器带宽：375kHz</p>
                          <p>数字滤波器中心频点：{{ formatF(item.id) }}</p>
                        </template>
                      </a-popover>
                      <div
                        v-else
                        @click="changeCheckSZLBQ(item.id)"
                        :class="!item.disabled ?(item.check ? 'oncheck' : 'offcheck') :(item.occupied?'occupiedCheck':'disabledStyle')"
                      >{{ item.label }}</div>
                    </div>
                  </div>
                </a-col>
              </a-row>
              <a-row>
                <a-col :span="24" :style="{ textAlign: 'right',marginRight:'30px' }">
                  <a-popconfirm title="确定修改配置吗?" @confirm="() => updateDigitalFilterPreAllocInfo()">
                    <a-button type="primary" style="margin-left: 10px">确认</a-button>
                  </a-popconfirm>
                  <!-- <a-popconfirm title="确定修改配置吗?" @confirm="() => handleSend()">
                    <a-button type="primary" style="margin-left: 10px">确认</a-button>
                  </a-popconfirm>-->

                  <!-- <a-button type="primary" style="margin-left: 10px" @click="handleSend">发送</a-button> -->
                </a-col>
              </a-row>
            </a-form-model>
          </a-card>
          <!-- <a-card title="数字滤波器开关状态" style="width: 100%">
            <a-form-model v-bind="layout" :model="formInline">
              <a-row>
                <a-col :span="24">
                  <a-form-model-item label="数字滤波器" :label-col="{ span: 3 }" :wrapper-col="{ span: 18 }">
                    <div style="line-height: 40px; color: #fff; display: flex; align-items: start">
                      <span class="on">开</span>
                      <span class="off">关</span>
                      <span class="dis">禁用</span>
                      <div style="display: flex; margin-left: 30px">
                        <p style="">注意:</p>
                        <p style="line-height: 20px; margin: 0">
                          1.数字滤波器配置尽量满足相邻的信道不同时处于“开”的状态<br />2.每次开启的数字滤波器个数固定为32个
                        </p>
                      </div>
                      <a-button type="primary" style="margin-left: 50px" @click="handleSend('SZLBQPZ')"> 发送</a-button>
                    </div>
                  </a-form-model-item></a-col
                >
                <a-col :span="24">
                  <div class="SZLBQList">
                    <div v-for="item in SZLBQList" :key="item.id" class="SZLBQBox">
                      <a-popover title="详情" v-if="!item.disabled">
                        <div
                          @click="changeCheckSZLBQ(item.id)"
                          :class="!item.disabled ? (item.check ? 'oncheck' : 'offcheck') : 'disabledStyle'"
                        >
                          {{ item.label }}
                        </div>
                        <template slot="content">
                          <p>数字滤波器编号：{{ item.id }}</p>
                          <p>数字滤波器带宽：375kHz</p>
                          <p>数字滤波器中心频点：{{ formatF(item.id) }}</p>
                        </template>
                      </a-popover>
                      <div
                        v-else
                        @click="changeCheckSZLBQ(item.id)"
                        :class="!item.disabled ? (item.check ? 'oncheck' : 'offcheck') : 'disabledStyle'"
                      >
                        {{ item.label }}
                      </div>
                    </div>
                  </div>
                </a-col>
              </a-row>
            </a-form-model>
          </a-card>-->
        </a-form-model>
      </a-collapse-panel>
      <a-collapse-panel key="2" header="控制指令发送及响应"></a-collapse-panel>
    </a-collapse>
    <creat-instruct ref="creatInstruct" />
    <configModal ref="configModal" />
    <a-modal :visible="visible" width="55%" title="资源分配申请表" @cancel="handleOk" @ok="handleOk">
      <template slot="footer">
        <a-button key="submit" type="primary" @click="handleOk">退出</a-button>
      </template>
      <a-table
        ref="table"
        size="middle"
        bordered
        rowKey="id"
        :columns="columnsSQB"
        :dataSource="dataSourceSQB"
        :pagination="ipagination"
        class="j-table-force-nowrap"
      >
        <span slot="action" slot-scope="text, record">
          <a-button @click="handleOk1(record)" type="primary">进入配置</a-button>
        </span>
      </a-table>
    </a-modal>
  </div>
</template>

<script>
import { processDefineKey } from '@/api/processDefineKey'
import CascaderSelect from './modules/Cascader.vue'
import creatInstruct from './modules/createInstruct'
import { getAction, httpAction } from '@/api/manage.js'
import configModal from './modules/confidModal.vue'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
//  <!-- 资源池 -->
import pool1 from './modules/resourcePool1.vue'
import { Turns, sum, hex2int } from '@/utils/util.js'
import { Select } from 'ant-design-vue'
export default {
  mixins: [JeecgListMixin],
  components: { creatInstruct, pool1, CascaderSelect, configModal },
  data() {
    return {
      selectSzArr: [],
      preAllocationResult: [], //所有车的预分配信息
      readOnly: false,
      visible: false,
      columnsSQB: [
        {
          title: '指挥车名称',
          dataIndex: 'ncvName',
          key: 'ncvName',
        },
        {
          title: '导弹总数',
          dataIndex: 'applyMissileTotal',
          key: 'applyMissileTotal',
        },
        {
          title: '信道号总数（个）',
          dataIndex: 'applyDigitalFilterTotal',
          key: 'applyDigitalFilterTotal',
        },
        {
          title: '操作',
          key: 'action',
          scopedSlots: { customRender: 'action' },
        },
      ],
      layout: {
        labelCol: { span: 4 },
        wrapperCol: { span: 14 },
      },
      formInline: { LControllableReceiver: "", localOscillator: '', cfp: '' },
      dataSourceSQB: [],
      carList: [],
      text: `world.`,
      value1: 'a',
      value2: '1',
      value3: 'a',
      poolData: [],
      tabActiveKey: '1',
      activeKey: ['1', '2'],
      labelCol: { span: 6 },
      wrapperCol: { span: 18 },
      labelCol1: { span: 8 },
      wrapperCol1: { span: 16 },
      form: {},
      fightForm: { startDate: undefined },
      form1: {},
      formUp: { Values: [], packageGridValue: '' },
      formBall: {},
      resourcesForm: {},
      resourcesList: [],
      resourcesNo: {},
      check: [],
      checkList: [],
      resourcesList: [],
      props: { multiple: true },
      ac: [
        { active: 1, disabled: [] },
        { active: 2, disabled: [] },
        { active: 3, disabled: [] },
        { active: 4, disabled: [] },
      ],
      das: null,
      multipleTreeData: [],
      url: {
        updateDigitalFilterPreAllocInfo: "/commandVehicle/nmcCommandVehicle/updateDigitalFilterPreAllocInfo",//修改与分配的频点信息
        getControllableReceiverInfo: "/telemetryInfo/nmcTelemetryInfo/getControllableReceiverInfo",
        getIntermediateFrequencyFilterInfo: '/telemetryInfo/nmcTelemetryInfo/getIntermediateFrequencyFilterInfo',
        getLocalOscillatorInfo: '/telemetryInfo/nmcTelemetryInfo/getLocalOscillatorInfo',
        getByFightDemandIdExcludeRetired: "/commandVehicle/nmcCommandVehicle/getByFightDemandIdExcludeRetired",
        sendConfig: "/commandVehicle/nmcCommandVehicle/doCommandVehicleMissileAlloc",
        queryInfo: '/commandVehicle/nmcCommandVehicle/getCommandVehicleMissileAllocInfo',
        getModalList: '/digitalFilter/nmcDigitalFilterApplyInfo/list',
        // getLatestPackageGridValue: '/grid/nmcPackageGridValue/getLatestPackageGridValue',
        sendPackage: '/channel/nmcChannelInfo/sendPackage',
        getNmcPackageGridValueByCode: '/grid/nmcPackageGridValue/code',
        nmcPackageGridList: '/grid/nmcPackageGrid/list',
        getBySpecifyDayOfCommandVehicleExcludeRetiredByFightDemandId: "/commandVehicle/nmcCommandVehicle/getBySpecifyDayOfCommandVehicleExcludeRetiredByFightDemandId",
        addnmcPackageGridValue: '/grid/nmcPackageGridValue/add', //{"packageGridValue":"22AA","Values":["22","aa"],"packageGridId":"1663806762680139777"}
      },
      localOscillatorList: [
        { label: '1', value: '1', cfp: '5540' },
        { label: '2', value: '2', cfp: '5560' },
        { label: '3', value: '3', cfp: '5580' },
        { label: '4', value: '4', cfp: '5600' },
        { label: '5', value: '5', cfp: '5620' },
        { label: '6', value: '6', cfp: '5640' },
        { label: '7', value: '7', cfp: '5660' },
        { label: '8', value: '8', cfp: '5680' },
        { label: '9', value: '8', cfp: '5700' },
        { label: '10', value: 'A', cfp: '5720' },
        { label: '11', value: 'B', cfp: '5740' },
        { label: '12', value: 'C', cfp: '5760' },
        { label: '13', value: 'D', cfp: '5780' },
        { label: '14', value: 'E', cfp: '5800' },
        { label: '15', value: 'F', cfp: '5820' },
      ],
      fightDemandCarSpreAllocationPoint:[],//当前任务的所有车的预分配频点信息
      occupiedZP:[],//被别的车占用的中频滤波器
      ZPLBQList: [
        {
          id: 0,
          label: '中频滤波器1',
          no: '01H',
          DK: '6',
          ZXPD: '939MHz',
          check: false,
          disabled: false,
          sz: [114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125],
        },
        {
          id: 1,
          label: '中频滤波器2',
          no: '02H',
          DK: '6',
          ZXPD: '944.25MHz',
          check: false,
          disabled: false,
          sz: [100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111],
        },
        {
          id: 2,
          label: '中频滤波器3',
          no: '03H',
          DK: '6',
          ZXPD: '949.5MHz',
          check: false,
          disabled: false,
          sz: [86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97],
        },
        {
          id: 3,
          label: '中频滤波器4',
          no: '04H',
          DK: '6',
          ZXPD: '954.75MHz',
          check: false,
          disabled: false,
          sz: [72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83],
        },
        {
          id: 4,
          label: '中频滤波器5',
          no: '05H',
          DK: '6',
          ZXPD: '960MHz',
          check: false,
          disabled: false,
          sz: [58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69],
        },
        {
          id: 5,
          label: '中频滤波器6',
          no: '06H',
          DK: '6',
          ZXPD: '965.25MHz',
          check: false,
          disabled: false,
          sz: [44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55],
        },
        {
          id: 6,
          label: '中频滤波器7',
          no: '07H',
          DK: '6',
          ZXPD: '970.5MHz',
          check: false,
          disabled: false,
          sz: [30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41],
        },
        {
          id: 7,
          label: '中频滤波器8',
          no: '08H',
          DK: '6',
          ZXPD: '975.75MHz',
          check: false,
          disabled: false,
          sz: [
            // 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
            27,
          ],
        },
        {
          id: 8,
          label: '中频滤波器9',
          no: '09H',
          DK: '6',
          ZXPD: '981MHz',
          check: false,
          disabled: false,
          sz: [],
          // sz: [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13],
        },
        {
          id: 9,
          label: '中频滤波器10',
          no: '10H',
          DK: '20',
          ZXPD: '960MHz',
          check: false,
          disabled: false,
          sz: [
            38, 39, 40, 41, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68,
            69, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 86, 87, 88, 89,
          ],
        },
      ],
      record: {},
      SZLBQList: [],
      rules: {
        localOscillator: [{ required: true, message: '请选择', trigger: 'change,blur' }],
        cfp: [{ required: false, message: '请选择', trigger: 'change' }],
        LControllableReceiver: [{ required: true, message: '请选择', trigger: 'change' }]
      },
      OccupiedArr:[],//当天被别的车占用的频点,
      z1:[],//z1当前任务所有
      z2:[],//z2当天除了当前任务的别的任务占用的频点
      z3:[],//z3当前任务除了当前车占用的频点
    }
  },
  watch: {
    activeKey(key) {
      console.log(key)
    },
  },
  active() {
    this.initBox() //生成128个数字滤波器
  },

  created() {
    this.initBox() //生成128个数字滤波器
    // this.getModalList()//获取要要配置的列表数据
  },
  methods: {
    emptyData() {
      this.form1 = {}
      this.formInline = { LControllableReceiver: '', localOscillator: '', cfp: '' }
      // this.SZLBQList = []
      this.record = {}
      this.ZPLBQList.forEach(item => {
        item.check = false
        item.disabled = false
      })
      this.OccupiedArr=[]//被占用数组也清空
      this.selectSzArr=[]
      this.initBox()

    },
    init(record) {
      console.log(record,'============init');
      this.record = record
            //请求任务对应的车
            getAction(this.url.getByFightDemandIdExcludeRetired, { fightDemandId: record.id }).then(res => {

                  this.carList = res.result//
                  console.log(this.carList,'当前任务的所有车的预分配频点信息');
                  let arr=[]
                  res.result.forEach(i=>{
                    arr.push(i.digitalFilterPreAllocInfo.split(','))
                  })
                  this.fightDemandCarSpreAllocationPoint= arr.flat()
                  console.log(this.fightDemandCarSpreAllocationPoint,'');
                  // this.fightDemandCarSpreAllocationPoint= //当前任务的所有车的预分配频点信息
                  })
                  //请求本任务当天所有车的频点预分配信息
                  getAction(this.url.getBySpecifyDayOfCommandVehicleExcludeRetiredByFightDemandId, { fightDemandId: record.id }).then(res => {

                  this.preAllocationResult = res.result //所有车的预分配信息
                  // console.log(res.result);
                  // this.digitalFilterAllocInfoArr = []
                  // this.preAllocationResult.forEach(i => {
                  //   this.preAllocationResultArr.push(i.digitalFilterAllocInfo)
                  // })
                  // this.carList = res.result
                  })
      this.formInline.LControllableReceiver=record.controllableReceiverPreAllocInfo
      this.formInline.localOscillator =record.localOscillatorPreAllocInfo
      this.formInline.cfp = this.localOscillatorList.find((i) => i.value == record.localOscillatorPreAllocInfo).cfp //本振编号联动中心频点
      let arr=record.intermediateFrequencyPreAllocInfo.split(',')
      let that=this
      arr.forEach(i => {
          // console.log(i, '中频滤波-----')
          that.changeCheckTrue(that.ZPLBQList.find(item => item.id == i))
        })

      //获取任务消息
    },
    getModalList() {
      getAction(this.url.getModalList, { pageSize: -1 }).then(res => {
        if (res.success) {
          if (res.result.records && res.result.records.length) {
            this.dataSourceSQB = res.result.records
          }
          else {
            this.dataSourceSQB = []
          }
        } else {
          this.$message.error(res.message)
        }

      })
    },
    formatF(n) {
      let m = Number(this.formInline.localOscillator)
      // console.log(1660.1875 + m * 20 + Number(n) * 0.375, '1660.1875 + m * 20 + Number(n) * 0.375')
      // console.log(Number(this.formInline.localOscillator), 'Number(this.formInline.localOscillator)')
      return 1660.1875 + m * 20 + Number(n) * 0.375
    },
    setBzValue(bz) {
      this.formInline.localOscillator = bz.slice(-1)//已配置的本振赋值
      this.changeLocalOscillator(bz.slice(-1))//中心频点赋值
    },
    // setZpValue(zp) {
    //   let b = zp//已配置的中频滤波器
    //   let results = Turns(b, 2).slice(0, -2).split('').reverse()
    //   results.forEach((i, index) => {
    //     if (i == 1) {
    //       this.changeCheckS(this.ZPLBQList.find((item, idx) => idx == index), 1)
    //     }
    //   })
    // },
    changeCar(val) {
      //在换车的时候要切换界面上车的中频 数字滤波器 中心频点等

      this.form1.applyDigitalFilterTotal = this.carList.find(i => i.identificationCode == val).missileUpChannelsNumber //信道申请数量
      this.form1.applyMissileTotal = this.carList.find(i => i.identificationCode == val).planApplyMissileTotal //计划导弹数量
      let obj = this.preAllocationResult.find(i => i.identificationCode == val)
      this.setSzValue(this.preAllocationResult, obj.digitalFilterPreAllocInfo)  //该车占用的频点

    },
    //被别的车占用的频点禁用
    setOccupiedPoint(arr=[],selectArr=[]){
      console.log(arr,selectArr)
      let z1=this.fightDemandCarSpreAllocationPoint //当前任务的所有频点组
      let z3=z1.filter(i=>arr.includes(i))
      let z2=selectArr.filter(item => !z1.includes(item))//当天除了当前任务的别的任务占用的频点
      this.OccupiedArr=[...z3] //被当天别的车选中的频点
      console.log(z3,'===========z3当前任务除了当前车占用的频点',);
      console.log(z2,'===========z2当天除了当前任务的别的任务占用的频点',);
      console.log(z1,'===========z1当前任务所有',);
      this.z1=z1
      this.z2=z2
      this.z3=z3
      this.SZLBQList.forEach((i, index) => {
        if (z2.indexOf(String(index)) != -1) {//别的任务的车选的 禁用置灰
         this.SZLBQList.find((item, idx) => idx == index).disabled = true
          this.SZLBQList.find((item, idx) => idx == index).check = false
          this.SZLBQList.find((item, idx) => idx == index).occupied = false
        }
        if (z3.indexOf(String(index)) != -1) {//当前任务别的车选的 禁用置黄
         this.SZLBQList.find((item, idx) => idx == index).disabled = true
          this.SZLBQList.find((item, idx) => idx == index).check = false
          this.SZLBQList.find((item, idx) => idx == index).occupied = true
        }
      })
    },
    setSzValue(result, sz) {
      let cxz = sz.split(',')//选中车分配的频点
      console.log(result,'resultresultresultresult 当天所有的车预分配信息');

      // this.formInline.sz = result.frequencyFilterOpenInfo.packageGridValue//32个数字滤波器
      let select = []//已选择的数字滤波器十进制编号
      result.forEach(i => {
        select.push(i.digitalFilterPreAllocInfo.split(','))
      })
      let selectArr = select.flat() //二维数组转一维 //当天所有的车的频点组

    //  console.log(selectArr,'this.selectArr');
      this.selectSzArr = cxz

      let arr = selectArr.filter(item => !cxz.includes(item)); //被当天别的车选中的频点

      this.OccupiedArr=[...arr] //被当天别的车选中的频点
      // console.log(arr,'被当天别的车选中的频点');
      // this.OccupiedArr=[...arr] //被当天别的车选中的频点
      this.SZLBQList.forEach((i, index) => {
        i.check = false

        if (cxz.indexOf(String(index)) != -1) {
          ////选中车分配的频点处于选中的状态，可修改
          this.SZLBQList.find((item, idx) => idx == index).disabled = false
          this.SZLBQList.find((item, idx) => idx == index).check = true
          this.SZLBQList.find((item, idx) => idx == index).occupied = false
        }
      })
      this.setOccupiedPoint(arr,selectArr)
    },
    setSzValueCopy(sz, result) {
      // console.log(sz, result)
      // this.formInline.sz = result.frequencyFilterOpenInfo.packageGridValue//32个数字滤波器
      let select = []//已选择的数字滤波器十进制编号
      result.nmcCommandVehicleVoList.forEach(i => {
        select.push(i.digitalFilterList)
      })
      let selectArr = select.flat()
      let result1 = this.Turns(sz, 2).split('').reverse()
      // console.log(result1, 'result1')
      this.SZLBQList.forEach((i) => {
        i.check = false
      })
      result1.forEach((i, index) => {
        if (i == 1) {
          if (selectArr.indexOf(String(index)) != -1) {
            // console.log(index, 'selectArr.indexOf(String(index)) != -1')
            this.SZLBQList.find((item, idx) => idx == index).disabled = true
            this.SZLBQList.find((item, idx) => idx == index).check = false
          }
        }
      })
    },
    // getLatestPackageGridValue() {
    //   const that = this
    //   let obj = { gridCode: '2-可控接收机本振频点切换指令', packageCode: '2星弹上行链路接收机频率配置1', processDefineKey: processDefineKey.SatelliteBombUpReceiverFreConfOneHandleImplKey }
    //   getAction(this.url.getLatestPackageGridValue, obj).then((res) => {
    //     let a = res.result.packageGridValue
    //     this.formInline.localOscillator = a.slice(-1)
    //     this.changeLocalOscillator(a.slice(-1))

    //   })
    //   let obj1 = { gridCode: '2-滤波器选通指令', packageCode: '2星弹上行链路接收机频率配置1', processDefineKey: processDefineKey.SatelliteBombUpReceiverFreConfOneHandleImplKey }
    //   getAction(this.url.getLatestPackageGridValue, obj1).then((res) => {
    //     let b = res.result.packageGridValue
    //     let result = Turns(b, 2).slice(0, -2).split('').reverse()
    //     result.forEach((i, index) => {
    //       if (i == 1) {
    //         this.changeCheckS(that.ZPLBQList.find((item, idx) => idx == index), 1)
    //       }
    //     })
    //   })

    //   let obj2 = { gridCode: '3-滤波器选通指令', packageCode: '3星弹上行链路接收机频率配置2', processDefineKey: processDefineKey.SatelliteBombUpReceiverFreConfTwoHandleImplKey }
    //   getAction(this.url.getLatestPackageGridValue, obj2).then((res) => {
    //     let a = res.result.packageGridValue
    //     let result = this.Turns(a, 2).split('').reverse()
    //     that.SZLBQList.forEach((i) => {
    //       i.check = false
    //     })
    //     result.forEach((i, index) => {
    //       if (i == 1) {
    //         that.SZLBQList.find((item, idx) => idx == index).check = true
    //         // this.changeCheckSZLBQ(that.SZLBQList.find((item, idx) => idx == index).id)
    //       }
    //     })
    //   })
    // },
    initBox() {
      this.SZLBQList = []
      for (let i = 0; i < 128; i++) {
        let obj = { id: i, disabled: true, check: false, label: i+1,occupied:false, }
        this.SZLBQList.push(obj)
      }
    },
    loadData() {
      // getAction(this.url.getLocalOscillatorInfo).then(res => {
      //   this.formInline.localOscillator = String(res.result)
      //   this.changeLocalOscillator(res.result)
      // })
      // getAction(this.url.getIntermediateFrequencyFilterInfo).then(res => {
      //   //中频滤波器=[0,1,2]
      //   let that = this
      //   res.result.forEach(i => {
      //     that.changeCheckTrue(this.ZPLBQList.find(item => item.id == i))
      //   })
      // })
      // getAction(this.url.getControllableReceiverInfo).then(res => {
      //   this.formInline.LControllableReceiver = res.result
      // })
    },
    changeCheckTrue(item) {
      // console.log(this.ZPLBQList, 'this.ZPLBQList')
      this.$nextTick(() => {
        // this.ZPLBQList.find((i) => i.id == item.id).check = true
        this.ZPLBQList.forEach(i => {
          if (i.id == item.id) {
            i.check = true
          }
        })
        let select = this.ZPLBQList.find((i) => i.id == item.id)
        item.sz.forEach((j) => {
          this.SZLBQList.find((x) => x.id == j).disabled = false
        })
        this.setOccupiedPoint(this.OccupiedArr)
      })

      // if (select.disabled) return
    },
    changeCheckSZLBQ(id) {
      if (!this.form1.ncvName) {
        this.$message.error('请选择指控车！')
        return
      }
      let select = this.SZLBQList.find((i) => i.id == id)
      // console.log(select, 'selectselectselect')
      if (select.disabled) return
      select.check = !select.check
      if(select.check){
        this.selectSzArr.push(String(id) )
      }else{
        this.selectSzArr=this.selectSzArr.filter((x) => x!= id)
      }

      console.log(this.selectSzArr,'==========id');
      // this.selectSzArr.filter((x) => x.check == true)
      // select.check = !select.check
      // console.log(this.SZLBQList.filter((x) => x.check == true))
    },
    changeCheck(item) {
      // console.log(item, 'item')
    },
    changeCheckS(item, type) {
      //点击中频滤波器
      //flag-如果选中包含当前车的数字滤波器的中频滤波器则终止操作并提示当前滤波器已被占用！
      let flag = false
      this.selectSzArr.forEach(i => {
        if (item.sz.indexOf(Number(i)) != -1) {
          flag = true
        }
      })
      if (flag) {
        this.$message.error('当前滤波器已被占用！')
        item.check = true
        return
      }

      //a-如果选中包含当前任务除了当前车占用的频点中频滤波器则终止操作并提示当前滤波器已被该任务别的车占用！！
        let a=false
          item.sz.forEach((j) => {
            if(this.z3.find(d=>d==j)){
                a=true
              }
          })
        if (a) {
        this.$message.error('当前滤波器已被该任务别的车占用！')
        item.check = true
        return
        }

        if (this.readOnly && !type) return //如果readOnly了 取消点击事件
        let id = item.id
        let select = this.ZPLBQList.find((i) => i.id == id)

        item.sz.forEach((j) => {
             this.SZLBQList.find((x) => x.id == j).disabled = select.check//打开选中的中频的数字滤波器
        })

        if (select.disabled) return
        select.check = !select.check//点击切换中频状态
        console.log(this.z2,'====z2当天除了当前任务的别的任务占用的频点');
        this.z2.forEach(i=>{
          if(select.check){
             this.SZLBQList.find((x) => x.id == i).disabled =true
            this.SZLBQList.find((x) => x.id == i).occupied=false
          }
          // else{
          //    this.SZLBQList.find((x) => x.id ==i).disabled =true
          //     this.SZLBQList.find((x) => x.id == i).occupied=true
          // }
        })
        let arr = [ '03H', '04H', '05H', '06H','07H',]
        let selectArr = [] //所有选中的no
        // this.SZLBQList = []
        this.ZPLBQList.forEach((i, index) => {
          if (i.check) {
            selectArr.push(i.no)
          }
          select.no == '10H' && arr.forEach((item) => i.no == item && (i.disabled = select.check))
        })
        //选中 2.3.4.5.6 中的一个
        let newArr = new Set(arr)
        let newselectArr = new Set(selectArr)
        let res = Array.from(new Set([...newArr].filter((x) => newselectArr.has(x)))) //获取两个set集合的交集用array.from返回
        this.ZPLBQList.find((i) => i.no == '10H').disabled = !!res.length
        // ------



      // let select = this.ZPLBQList.find((i) => i.id == id)
      // if (select.disabled) return
      // select.check = !select.check

      // let arr = ['2H', '3H', '4H', '5H', '6H']
      // let selectArr = [] //所有选中的no
      // this.ZPLBQList.forEach((item, index) => {
      //   if (item.check) {
      //     selectArr.push(item.no)
      //   }
      // })
      // //选中 2.3.4.5.6 中的一个
      // if (arr.indexOf(select.no) != -1) {
      //   if (select.check) {
      //     //选中为开
      //     this.ZPLBQList.find((i) => i.no == '9H').disabled = true
      //   } else if (!select.check) {
      //     //选中为关
      //     //保证所有选中中没有2，3，4，5，6
      //     let flag = true
      //     arr.forEach((j) => {
      //       if (selectArr.indexOf(j) > -1) {
      //         flag = false
      //       }
      //     })
      //     if (flag) {
      //       this.ZPLBQList.find((i) => i.no == '9H').disabled = false
      //     }
      //   }
      // }
      // //选中9H
      // if (select.no == '9H') {
      //   this.ZPLBQList.forEach((i) => {
      //     arr.forEach((item) => {
      //       if (i.no == item) {
      //         if (select.check) {
      //           i.disabled = true
      //         } else {
      //           i.disabled = false
      //         }
      //       }
      //     })
      //   })
      //   // 2.3.4.5.6 禁用
      // }
    },
    changeLocalOscillator(val) {
      this.formInline.cfp = this.localOscillatorList.find((i) => i.value == val).cfp //本振编号联动中心频点

      // this.ZPLBQList.forEach(item => {
      //   item.check = false
      // })
      // this.SZLBQList.forEach(item => {
      //   item.disabled = true
      //   item.occupied = false
      //   item.check = false
      // })
      // this.selectSzArr=[]
      // this.OccupiedArr=[]//占用频点数组
      this.$forceUpdate()

      //请求查询该本振下的中频滤波器和数字滤波器的打开状态
    },
    handleOk() {
      this.$router.back()
    },
    handleOk1(record) {
      // this.visible = false
      // this.form1 = record
      // // this.getLatestPackageGridValue()//获取最新值
      // getAction(this.url.queryInfo).then(res => {
      //   let result = res.result
      //   console.log(result, 'result')
      //   if (result.nmcCommandVehicleVoList.length > 0) {
      //     //有指控车配置过中频滤波器和本振（则不可修改）中频滤波器和本振
      //     this.readOnly = true
      //     this.setBzValue(result.localFrequencyPoint.packageGridValue)
      //     this.setZpValue(result.intermediateFrequencyFilter.packageGridValue)
      //     this.setSzValue(result.frequencyFilterOpenInfo.packageGridValue, result)
      //     return
      //   } else {
      //     this.readOnly = false
      //   }
      // })
      // record.configured = true
      // if (record.configured) {

      //   this.readOnly = true //不可修改
      //   //如果已经配置过了configured为true，中频滤波器与本振编号已有且不可修改，数组滤波器的可选项固定
      //   let zplbqValue = [2, 3, 4]//中频滤波器的数值
      //   let selectZP = []
      //   zplbqValue.forEach(item => {
      //     if (this.ZPLBQList.find(i => i.id == item)) {
      //       selectZP.push(this.ZPLBQList.find(i => i.id == item))
      //     }
      //   })
      //   console.log(selectZP, '已经配置的中频滤波器可读不可写')
      //   selectZP.forEach(item => {
      //     this.changeCheckS(item, 1)//界面展示已经配置的中频滤波器
      //   })
      //   let bzbhValue = 3//本振编号的数值
      //   this.formInline.localOscillator = bzbhValue
      //   this.changeLocalOscillator(bzbhValue)//联动中心频点
      //   let selectedArr = [72, 73, 74, 75, 76, 77, 78, 79, 80]

      //   this.SZLBQList.forEach(i => {
      //     console.log(i, '数字滤波器的item')
      //     if (selectedArr.indexOf(Number(i.id)) !== -1) {
      //       //不是可选数组里的都禁用
      //       i.disabled = false
      //     } else {
      //       i.disabled = true
      //     }
      //   })
      // }
    },
    getValueByCodeBall() {
      getAction(`${this.url.getNmcPackageGridValueByCode}/${encodeURI('4-信道')}`).then((res) => {
        let temp = res.result
        this.formBall.packageGridId = '4-信道'
        let tempData = Turns(temp.packageGridValue, 4)
        tempData.forEach((i) => {
          this.$refs.pool.subData.find((item) => item.id == i).check = true
        })
        // console.log(tempData, 'this.Turns(tempData, 4)')
        // this.$refs.pool1.subData = JSON.parse(JSON.stringify(end))
        // this.upLength = temp.packageGrid.gridStaticLength
        // this.$set(this.formUp, 'Values', [...this.StringToArr(temp.packageGridValue)])
      })
    },
    ballConfig(val) {
      let act = this.$refs.pool.subData.filter((i) => i.check == true)
      let str = ''
      act.forEach((i, index) => {
        str += i.id.toString(16).padStart(4, 0).toUpperCase()
      })
      if (val == '4-信道') {
        this.formBall.packageGridValue = str.toUpperCase()
        httpAction(this.url.addnmcPackageGridValue, this.formBall, 'post').then((res) => {
          this.visibleAdd = false
          if (res.success) {
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
      }
    },
    Turns(str, type) {
      if (type == 16) {
        //8位二进制数转2位十六进制数
        let d = []
        let c = str
        for (let i = 0; i < c.length; i += 4) {
          d.push(c.slice(i, i + 4))
        }
        let items = ''
        d.forEach((item) => {
          // 把num当做2进制的值 转换为10进制
          item = JSON.parse(JSON.stringify(parseInt(item, 2).toString(16)))
          items += item
        })
        return items.toUpperCase()
      }

      if (type == 2) {
        //十六进制转8位二进制数
        let d = []
        let c = str
        for (let i = 0; i < c.length; i += 1) {
          d.push(c.slice(i, i + 1))
        }
        let items = ''
        d.forEach((item) => {
          item = JSON.parse(JSON.stringify(parseInt(item, 16).toString(2))).padStart(4, 0)
          items += item
        })
        return items
      }
    },
    updateDigitalFilterPreAllocInfo() {

      let str1 = ''
      let a = []
      this.SZLBQList.forEach((i, index) => {
        str1 += i.check && !i.disabled ? 1 : 0
        if (i.check && !i.disabled) {
          a.push(index)
        }
      })
      // console.log(a, '十进制编号')
      let arr = []
      this.ZPLBQList.forEach((item, indx) => {
        if (item.check && !item.disabled) {
          arr.push(item.id)
        }
      })
      if (!this.form1.ncvName) {
        this.$message.error('请选择指控车！')
        return
      }
      if (!a.length) {
        this.$message.error('请选择数字滤波器！')
        return
      } else if (a.length != this.form1.applyDigitalFilterTotal) {
        this.$message.error(`本次开启的数字滤波器个数固定为${this.form1.applyDigitalFilterTotal}个,本次选中${sum(str1, '1')}个`)
        return
      }

      let data =
      {
        "digitalFilterPreAllocInfo": a.join(),
        "fightDemandId": this.record.id,
        "identificationCode": this.form1.ncvName,
        'controllableReceiverPreAllocInfo': this.formInline.LControllableReceiver,
        'intermediateFrequencyPreAllocInfo': arr.join(),
        'localOscillatorPreAllocInfo': this.formInline.localOscillator
      }

      // console.log(data, 'data发送参数')
      // return
      httpAction(this.url.updateDigitalFilterPreAllocInfo, data, 'post').then(res => {
        if (res.code == 200) {
          this.$message.success(res.message)
        } else {
          this.$message.error(res.message)
        }
      })


    },
    handleSend() {
      let flag = false
      let params = {
        nmcPackageGridValues: [
          {
            gridCode: '',
            packageGridValue: '',
          },
          {
            gridCode: '',
            packageGridValue: '',
          },
        ],
        packageCode: '',
      }
      let that = this
      // console.log(this.formInline, 'this.formInline')
      let str = ''
      let selectArr = []
      this.ZPLBQList.forEach((i) => {
        str += i.check ? 1 : 0
        if (i.check) selectArr.push(i)
      })
      let DKsum = 0
      selectArr.forEach(i => {
        DKsum += Number(i.DK)
      })
      if (DKsum < 18) {
        // if (DKsum > 20 || DKsum < 18) {
        that.$message.error('请保持选择带宽大于等于18MHz')
        // that.$message.error('请保持选择带宽小于20MHz大于等于18MHz')
        return
      }
      let aaa = str.split('').reverse().join('').padEnd(12, 0) //先反转在补零，
      let packageGridValue = this.Turns(aaa, 16)
      this.$refs.ruleFormZP.validate((valid) => {
        if (valid) {
          if (packageGridValue == '000') {
            that.$message.error('请选择中频滤波器')
            return
          } else {
            params.packageCode = '2星弹上行链路接收机频率配置1'
            params.nmcPackageGridValues[0].gridCode = '2-可控接收机本振频点切换指令'
            params.nmcPackageGridValues[0].packageGridValue = this.formInline.localOscillator.padStart(4, 0)
            params.nmcPackageGridValues[1].gridCode = '2-滤波器选通指令'
            params.nmcPackageGridValues[1].packageGridValue = this.Turns(aaa, 16).padStart(4, 0)
            flag = true
          }
        } else {
          return
        }
      })

      let params1 = {
        nmcPackageGridValues: [
          {
            batchId: '',
            gridCode: '',
            packageGridValue: '',
          },
        ],
        packageCode: '',
      }
      let str1 = ''
      let a = []
      this.SZLBQList.forEach((i, index) => {
        str1 += i.check && !i.disabled ? 1 : 0
        if (i.check && !i.disabled) {
          a.push(index)
        }
      })
      // console.log(a, '十进制编号')


      if (str1.indexOf('1') == -1) {
        this.$message.error('请选择数字滤波器~')
        return
      } else if (sum(str1, '1') != this.form1.applyDigitalFilterTotal) {
        this.$message.error(`本次开启的数字滤波器个数固定为${this.form1.applyDigitalFilterTotal}个,本次选中${sum(str1, '1')}个`)
        return
      }
      let sz = str1.split('').reverse().join('')
      let packageGridValueSZ = this.Turns(sz, 16)
      params1.packageCode = '3星弹上行链路接收机频率配置2'
      params1.nmcPackageGridValues[0].gridCode = '3-滤波器选通指令'
      params1.nmcPackageGridValues[0].packageGridValue = packageGridValueSZ
      let digitalFilterAllocInfo = a.join()
      // console.log(this.form1, 'this.form1')
      let data = {
        "localFrequencyPoint": params,
        "nmcCommandVehicleDto": {
          "digitalFilterAllocInfo": digitalFilterAllocInfo,
          "identificationCode": this.form1.ncvIdentificationCode
        }
      }
      if (flag) {
        // console.log(data, 'data发送参数')
        // return
        httpAction(this.url.sendConfig, data, 'post').then(res => {
          if (res.code == 200) {
            that.$message.success('发包成功！')
            this.visible = true
            this.getModalList()
          } else {
            that.$message.error('发包失败！')
          }
        })
        // httpAction(this.url.sendPackage, params, 'post').then((res) => {
        //   if (res.code == 200) {
        //     that.$message.success('发包成功！')
        //   } else {
        //     that.$message.error('发包失败！')
        //   }
        // })
        // httpAction(this.url.sendPackage, params1, 'post').then((res) => {
        //   if (res.code == 200) {
        //     that.$message.success('发包成功！')
        //   } else {
        //     that.$message.error('发包失败！')
        //   }
        // })
      }


    },
    //发送事件
    handleSend1(val) {
      let params = {
        nmcPackageGridValues: [
          {
            batchId: '',
            gridCode: '',
            packageGridValue: '',
          },
        ],
        packageCode: '',
      }
      let that = this
      if (val == 'ZPLBQPZ') {
        // console.log(this.formInline, 'this.formInline')
        let str = ''
        this.ZPLBQList.forEach((i) => {
          str += i.check ? 1 : 0
        })
        let aaa = str.split('').reverse().join('').padEnd(12, 0) //先反转在补零，
        let packageGridValue = this.Turns(aaa, 16)
        this.$refs.ruleFormZP.validate((valid) => {
          if (valid) {
            if (packageGridValue == '000') {
              that.$message.error('请选择中频滤波器')
              return
            } else {
              params.packageCode = '2星弹上行链路接收机频率配置1'
              params.nmcPackageGridValues[0].gridCode = '2-可控接收机本振频点切换指令'
              params.nmcPackageGridValues[0].packageGridValue = this.formInline.localOscillator + this.Turns(aaa, 16)
              httpAction(this.url.sendPackage, params, 'post').then((res) => {
                if (res.code == 200) {
                  that.$message.success('发包成功！')
                } else {
                  that.$message.error('发包失败！')
                }
              })
            }
          } else {
            return
          }
        })
      } else if (val == 'SZLBQPZ') {
        let str = ''
        this.SZLBQList.forEach((i) => {
          str += i.check && !i.disabled ? 1 : 0
        })
        // console.log(sum(str, '1'), 'this.this.sum(str, ) !== 2')
        if (str.indexOf('1') == -1) {
          this.$message.error('请选择数字滤波器~')
          return
        } else if (sum(str, '1') !== 5) {
          this.$message.error(`每次开启的数字滤波器个数固定为32个,本次选中${sum(str, '1')}个`)
          return
        }
        let sz = str.split('').reverse().join('')
        let packageGridValueSZ = this.Turns(sz, 16)
        params.packageCode = '3星弹上行链路接收机频率配置2'
        params.nmcPackageGridValues[0].gridCode = '3-滤波器选通指令'
        params.nmcPackageGridValues[0].packageGridValue = packageGridValueSZ
        httpAction(this.url.sendPackage, params, 'post').then((res) => {
          if (res.code == 200) {
            that.$message.success('发包成功！')
          } else {
            that.$message.error('发包失败！')
          }
        })
      }

      // this.$refs.selectChannel.showModal(temp)
    },
    handleConfig() {
      this.$refs.configModal.showModal({}, 'ball')
    },
    // 工程量值根据Code回显
    getValueByCode() {
      // let url = escape(` ${this.url.getNmcPackageGridValueByCode}/'8-星指下行链路接收机变频器频点号'`)
      // getAction(url).then((res) => {
      getAction(`${this.url.getNmcPackageGridValueByCode}/${encodeURI('8-星指下行链路接收机变频器频点号')}`).then(
        (res) => {
          let temp = res.result
          this.form.packageGridId = '8-星指下行链路接收机变频器频点号'
          this.length = temp.packageGrid.gridStaticLength
          this.form.packageGridValue = hex2int(temp.packageGridValue)
          // this.$set(this.form, 'Values', [...this.StringToArr(temp.packageGridValue)])
        }
      )
      getAction(`${this.url.getNmcPackageGridValueByCode}/${encodeURI('9-星指上行链路接收机变频器频点号')}`).then(
        (res) => {
          let temp = res.result
          this.formUp.packageGridId = '9-星指上行链路接收机变频器频点号'
          this.upLength = temp.packageGrid.gridStaticLength
          this.formUp.packageGridValue = hex2int(temp.packageGridValue) < 1921 ? hex2int(temp.packageGridValue) : '0'
          // console.log(temp.packageGridValue, hex2int(temp.packageGridValue))
          // this.$set(this.formUp, 'Values', [...this.StringToArr(temp.packageGridValue)])
        }
      )
      getAction(`${this.url.getNmcPackageGridValueByCode}/${encodeURI('6-分配给车1的时隙号')}`).then((res) => {
        let temp = res.result
        this.resourcesForm.packageGridId = '6-分配给车1的时隙号'
        let tempData = temp.packageGridValue.slice(-8)
        let data = Turns(tempData, 2).split('')
        let Arr = []
        data.forEach((item, index) => {
          Arr.push({
            id: data.length - index,
            check: item == 0 ? true : false, //可用是1，否是0
          })
        })
        Arr.shift()
        Arr.shift()
        let end = [...Arr.reverse()]
        this.$refs.pool1.subData = JSON.parse(JSON.stringify(end))
      })
      // getAction(`${this.url.getNmcPackageGridValueByCode}/${encodeURI('6-分配给指挥车1的时隙个数')}`).then((res) => {
      //   let temp = res.result
      //   this.resourcesNo.packageGridId = '6-分配给指挥车1的时隙个数'
      //   this.resourcesNo.No = res.result.packageGridValue
      // })
    },

    handleValues(val) {
      if (val == '8-星指下行链路接收机变频器频点号') {
        // this.form.packageGridValue = this.form.Values.join('').toUpperCase()
        this.form.packageGridValue = this.form.packageGridValue.toString(16).padStart(4, 0)
        httpAction(this.url.addnmcPackageGridValue, this.form, 'post').then((res) => {
          this.visibleAdd = false
          if (res.success) {
            this.getValueByCode()
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
      } else if (val == '9-星指上行链路接收机变频器频点号') {
        this.formUp.packageGridValue = this.formUp.packageGridValue.toString(16).padStart(4, 0)
        // this.formUp.packageGridValue = this.formUp.Values.join('').toUpperCase()
        httpAction(this.url.addnmcPackageGridValue, this.formUp, 'post').then((res) => {
          this.visibleAdd = false
          if (res.success) {
            this.getValueByCode()
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
      } else if (val == '6-分配给车1的时隙号') {
        let subData = this.reverseAndConvert(this.$refs.pool1.subData)
        let str = ''
        subData.forEach((i) => {
          str += i.data
        })
        let strs = str.padStart(62, 1).padStart(64, 0)
        let temp = Turns(strs, 16) //6-分配给车1的时隙号
        this.resourcesForm.packageGridValue = temp
        httpAction(this.url.addnmcPackageGridValue, this.resourcesForm, 'post').then((res) => {
          this.visibleAdd = false
          if (res.success) {
            this.getValueByCode()
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })

        this.resourcesNo.packageGridId = '6-分配给指挥车1的时隙个数'
        // console.log(this.$refs.pool1.checkGroup)
        this.resourcesNo.packageGridValue = this.$refs.pool1.checkGroup.length.toString(16).padStart(4, 0).toUpperCase() //分配的数值
        // console.log(this.resourcesNo, 'this.resourcesNo')
        // return
        httpAction(this.url.addnmcPackageGridValue, this.resourcesNo, 'post').then((res) => {
          this.visibleAdd = false
          if (res.success) {
            this.$message.success(res.message)
          } else {
            this.$message.warning(res.message)
          }
        })
      }
    },
    changeCarCounts(val) {
      this.multipleTreeData = []
      let children = []
      for (let i = 1; i <= 32; i++) {
        children.push({
          id: `${i}-1`,
          value: `导弹${i}`,
          label: `导弹${i}`,
        })
      }
      for (let i = 1; i <= val; i++) {
        this.multipleTreeData.push({
          id: i,
          value: `指挥车${i}`,
          label: `指挥车${i}`,
          children: [...children],
        })
      }
    },

    creatInstruct() { },
    handleCreatInstruct() {
      //指令一键生成
      this.$refs.creatInstruct.showModal(this.fightForm)
      // console.log(this.fightForm)
    },
    handleChange(value) {
      console.log(`selected ${value}`)
    },
    onSubmit() {
      console.log(this.form)
    },
    onChange1(checkedValues) {
      console.log('checked = ', checkedValues)
    },
    onChange(e) {
      this.resourcesList.forEach((i) => {
        if (i.active == this.tabActiveKey) {
          i.disabled = false
        }
        e.forEach((item) => {
          if (i.label == item) {
            i.disabled = true
            i.active = this.tabActiveKey
          }
        })
      })
    },
    callback(key) {
      this.tabActiveKey = key
      this.ac.forEach((i, index) => {
        if (i.active == this.tabActiveKey) {
          this.ac.splice(index, 1)
        }
      })
    },
    filter(val) {
      if (this.checkList.indexOf(val) != -1) {
        return true
      } else {
        return false
      }
    },
  },
}
</script>
<style lang="less">
.ant-input-group-wrapper .ant-input-wrapper .ant-input-group-addon {
  color: #fff;
}
.taskAllocation {
  .ant-checkbox-group {
    // height: 300px;
    // line-height: 0.9;
    .ant-checkbox-wrapper {
      margin: 0;
    }
    .ant-col {
      width: auto;
      margin: 0;
    }
  }
}
.tabs .ant-row {
  width: 600px;
  .ant-checkbox-inner {
    width: 40px !important;
    height: 40px !important;
    text-align: center;
    &::after {
      width: 7px;
      height: 14px;
      left: 35%;
    }
  }
}
.ant-checkbox-inner {
  /* background-color: red !important; */
  border-color: #6e6e6e !important;
}
.ant-form-item-control {
  line-height: 0 !important;
}
.on,
.off,
.occ,
.dis {
  color: #fff;
  margin-right: 8px;
  margin-left: 8px;
  font-size: 20px;
  line-height: 40px;
}
.on::after {
  content: '';
  display: inline-block;
  height: 16px;
  width: 16px;
  line-height: 40px;
  // border: 0.1px solid #7e7c7c;
  margin-left: 15px;
  background: #36f73f;
}
.occ::after{
  content: '';
  display: inline-block;
  height: 16px;
  width: 16px;
  line-height: 20px;
  // border: 0.1px solid #7e7c7c;
  margin-left: 15px;
  background: linear-gradient(
    45deg,
    rgba(255, 165, 0, 0.6) 0,
    rgba(255, 165, 0, 0.6) 10%,
    rgb(113, 138, 125) 10%,
    rgb(113, 138, 125) 20%,
    rgba(255, 165, 0, 0.6) 20%,
    rgba(255, 165, 0, 0.6) 30%,
    rgb(113, 138, 125) 30%,
    rgb(113, 138, 125) 40%,
    rgba(255, 165, 0, 0.6) 40%,
    rgba(255, 165, 0, 0.6) 50%,
    rgb(113, 138, 125) 50%,
    rgb(113, 138, 125)60%,
    rgba(255, 165, 0, 0.6) 60%,
    rgba(255, 165, 0, 0.6) 70%,
    rgb(113, 138, 125) 70%,
    rgb(113, 138, 125) 80%,
    rgba(255, 165, 0, 0.6) 80%,
    rgba(255, 165, 0, 0.6) 90%,
    rgb(113, 138, 125) 90%,
    rgb(113, 138, 125) 100%
  );
}
.off::after {
  content: '';
  display: inline-block;
  height: 16px;
  width: 16px;
  line-height: 20px;
  // border: 0.1px solid #7e7c7c;
  margin-left: 15px;
  background: #f51616;
}
.dis::after {
  content: '';
  display: inline-block;
  height: 16px;
  width: 16px;
  line-height: 20px;
  // border: 0.1px solid #7e7c7c;
  margin-left: 15px;
  background: linear-gradient(
    45deg,
    rgba(117, 117, 117, 0.6) 0,
    rgba(117, 117, 117, 0.6) 10%,
    rgba(42, 44, 43, 1) 10%,
    rgba(42, 44, 43, 1) 20%,
    rgba(117, 117, 117, 0.6) 20%,
    rgba(117, 117, 117, 0.6) 30%,
    rgba(42, 44, 43, 1) 30%,
    rgba(42, 44, 43, 1) 40%,
    rgba(117, 117, 117, 0.6) 40%,
    rgba(117, 117, 117, 0.6) 50%,
    rgba(42, 44, 43, 1) 50%,
    rgba(42, 44, 43, 1) 60%,
    rgba(117, 117, 117, 0.6) 60%,
    rgba(117, 117, 117, 0.6) 70%,
    rgba(42, 44, 43, 1) 70%,
    rgba(42, 44, 43, 1) 80%,
    rgba(117, 117, 117, 0.6) 80%,
    rgba(117, 117, 117, 0.6) 90%,
    rgba(42, 44, 43, 1) 90%,
    rgba(42, 44, 43, 1) 100%
  );
}
.ZPLBQList {
  width: 100%;
  display: flex;
  // flex: 1;
  .ZPLBQBox {
    flex: auto;
    user-select: none;
    .offcheck,
    .oncheck,
    .occupiedCheck,
    .disabledStyle {
      line-height: 60px;
    }
  }
}
.SZLBQList {
  width: 100%;
  display: flex;
  flex-wrap: wrap;
  .SZLBQBox {
    width: 40px;
    height: 40px;
    line-height: 40px;
    user-select: none;
    // border: 1px solid #ad1616;
    .offcheck,
    .occupiedCheck,
    .oncheck,
    .disabledStyle {
      line-height: 40px;
    }
  }
}
.offcheck,
.occupiedCheck,
.oncheck,
.disabledStyle {
  width: 100%;
  height: 100%;
  border: 1px solid #7e7979;
  margin: -1px 0 0 -1px;
  text-align: center;
}
.offcheck {
  color: #000;
  background: #f51616;
}
.disabledStyle {
  color: #898383;
  // background: #868686;
  background: linear-gradient(
    45deg,
    rgba(117, 117, 117, 0.6) 0,
    rgba(117, 117, 117, 0.6) 10%,
    rgba(42, 44, 43, 1) 10%,
    rgba(42, 44, 43, 1) 20%,
    rgba(117, 117, 117, 0.6) 20%,
    rgba(117, 117, 117, 0.6) 30%,
    rgba(42, 44, 43, 1) 30%,
    rgba(42, 44, 43, 1) 40%,
    rgba(117, 117, 117, 0.6) 40%,
    rgba(117, 117, 117, 0.6) 50%,
    rgba(42, 44, 43, 1) 50%,
    rgba(42, 44, 43, 1) 60%,
    rgba(117, 117, 117, 0.6) 60%,
    rgba(117, 117, 117, 0.6) 70%,
    rgba(42, 44, 43, 1) 70%,
    rgba(42, 44, 43, 1) 80%,
    rgba(117, 117, 117, 0.6) 80%,
    rgba(117, 117, 117, 0.6) 90%,
    rgba(42, 44, 43, 1) 90%,
    rgba(42, 44, 43, 1) 100%
  );
}
.oncheck {
  color: #000;
  background: #36f73f;
}
.occupiedCheck{

  color: #000;
  // background: orange;
  background: linear-gradient(
    45deg,
    rgba(255, 165, 0, 0.6) 0,
    rgba(255, 165, 0, 0.6) 10%,
    rgb(113, 138, 125) 10%,
    rgb(113, 138, 125) 20%,
    rgba(255, 165, 0, 0.6) 20%,
    rgba(255, 165, 0, 0.6) 30%,
    rgb(113, 138, 125) 30%,
    rgb(113, 138, 125) 40%,
    rgba(255, 165, 0, 0.6) 40%,
    rgba(255, 165, 0, 0.6) 50%,
    rgb(113, 138, 125) 50%,
    rgb(113, 138, 125)60%,
    rgba(255, 165, 0, 0.6) 60%,
    rgba(255, 165, 0, 0.6) 70%,
    rgb(113, 138, 125) 70%,
    rgb(113, 138, 125) 80%,
    rgba(255, 165, 0, 0.6) 80%,
    rgba(255, 165, 0, 0.6) 90%,
    rgb(113, 138, 125) 90%,
    rgb(113, 138, 125) 100%
  );
}
.has-error .ant-input,
.has-error .ant-input:hover {
  background-color: transparent;
  border: 1px solid #17dcff;
}
</style>
